!include x64.nsh

Name "编玩边学Arduino助手"
Icon "codepku.ico"
OutFile "编玩边学Arduino助手.exe"

InstallDir "$PROGRAMFILES\CodePKu-Arduino"

; LicenseText "编玩边学软件使用许可协议"
; LicenseData "license.txt"
BrandingText "编玩边学"

ShowInstDetails show


; Page license
Page directory
Page instfiles

Section "" ;No components page, name is not important

  ; Set output path to the installation directory.
  SetOutPath $INSTDIR

  ; Put file there
  File /r CodePKu-Arduino
  
  ; install drivers
  ${If} ${RunningX64}
    ; 64 bit code
    Exec $INSTDIR\CodePKu-Arduino\Arduino\drivers\dpinst-amd64.exe
  ${Else}
    ; 32 bit code
    Exec $INSTDIR\CodePKu-Arduino\Arduino\drivers\dpinst-x86.exe
  ${EndIf}
  
  Exec $INSTDIR\CodePKu-Arduino\Arduino\drivers\CH341SER.EXE
  
  SetOutPath $INSTDIR\CodePKu-Arduino
  SetShellVarContext all ; create shortcut for all users
  CreateShortcut "$DESKTOP\编玩边学Arduino助手.lnk" "$INSTDIR\CodePKu-Arduino\codepku-arduino-32.exe" "" "$INSTDIR\CodePKu-Arduino\codepku.ico" 0
  WriteUninstaller "Uninst.exe"

SectionEnd ;

UninstPage uninstConfirm
UninstPage instfiles

UninstallText "您将卸载编玩边学Arduino助手，点击下一步继续。"
Section "Uninstall"
  Delete $INSTDIR\Uninst.exe ; delete self (see explanation below why this works)
  Delete "$DESKTOP\编玩边学Arduino助手.lnk"
  RMDir /r $INSTDIR\CodePKu-Arduino
  RMDir $INSTDIR
SectionEnd
